﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace text.StrProblem
{
    public class _415
    {
        public static string Reverse(string original)
        {
            char[] arr = original.ToCharArray();
            Array.Reverse(arr);
            return new string(arr);
        }
        public static string AddStrings(string num1, string num2)
        {
            StringBuilder sb = new StringBuilder();
            int carry = 0, i = num1.Length - 1, j = num2.Length - 1;
            while (i >= 0 || j >= 0 || carry != 0)
            {
                if (i >= 0) carry += Convert.ToInt32(num1[i--].ToString());
                if (j >= 0) carry += Convert.ToInt32(num2[j--].ToString());
                sb.Append(carry % 10);
                carry /= 10;
            }
            return Reverse(sb.ToString()).ToString();
        }
    }
}
